home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / perl / 5.10.0 / ExtUtils / CBuilder / Platform / os2.pm < prev    next >
Encoding:
Perl POD Document  |  2009-06-26  |  2.7 KB  |  81 lines

  1. package ExtUtils::CBuilder::Platform::os2;
  2.  
  3. use strict;
  4. use ExtUtils::CBuilder::Platform::Unix;
  5.  
  6. use vars qw($VERSION @ISA);
  7. $VERSION = '0.21';
  8. @ISA = qw(ExtUtils::CBuilder::Platform::Unix);
  9.  
  10. sub need_prelink { 1 }
  11.  
  12. sub prelink {
  13.   # Generate import libraries (XXXX currently near .DEF; should be near DLL!)
  14.   my $self = shift;
  15.   my %args = @_;
  16.  
  17.   my @res = $self->SUPER::prelink(%args);
  18.   die "Unexpected number of DEF files" unless @res == 1;
  19.   die "Can't find DEF file in the output"
  20.     unless $res[0] =~ m,^(.*)\.def$,si;
  21.   my $libname = "$1$self->{config}{lib_ext}";    # Put .LIB file near .DEF file
  22.   $self->do_system('emximp', '-o', $libname, $res[0]) or die "emxexp: res=$?";
  23.   return (@res, $libname);
  24. }
  25.  
  26. sub _do_link {
  27.   my $self = shift;
  28.   my ($how, %args) = @_;
  29.   if ($how eq 'lib_file'
  30.       and (defined $args{module_name} and length $args{module_name})) {
  31.  
  32.     # DynaLoader::mod2fname() is a builtin func
  33.     my $lib = DynaLoader::mod2fname([split /::/, $args{module_name}]);
  34.  
  35.     # Now know the basename, find directory parts via lib_file, or objects
  36.     my $objs = ( (ref $args{objects}) ? $args{objects} : [$args{objects}] );
  37.     my $near_obj = $self->lib_file(@$objs);
  38.     my $ref_file = ( defined $args{lib_file} ? $args{lib_file} : $near_obj );
  39.     my $lib_dir = ($ref_file =~ m,(.*)[/\\],s ? "$1/" : '' );
  40.     my $exp_dir = ($near_obj =~ m,(.*)[/\\],s ? "$1/" : '' );
  41.  
  42.     $args{dl_file} = $1 if $near_obj =~ m,(.*)\.,s; # put ExportList near OBJ
  43.     $args{lib_file} = "$lib_dir$lib.$self->{config}{dlext}";    # DLL file
  44.  
  45.     # XXX _do_link does not have place to put libraries?
  46.     push @$objs, $self->perl_inc() . "/libperl$self->{config}{lib_ext}";
  47.     $args{objects} = $objs;
  48.   }
  49.   # Some 'env' do exec(), thus return too early when run from ksh;
  50.   # To avoid 'env', remove (useless) shrpenv
  51.   local $self->{config}{shrpenv} = '';
  52.   return $self->SUPER::_do_link($how, %args);
  53. }
  54.  
  55. sub extra_link_args_after_prelink {
  56.   # Add .DEF file to the link line
  57.   my ($self, %args) = @_;
  58.  
  59.   my @DEF = grep /\.def$/i, @{$args{prelink_res}};
  60.   die "More than one .def files created by `prelink' stage" if @DEF > 1;
  61.   # XXXX No "$how" argument here, so how to test for dynamic link?
  62.   die "No .def file created by `prelink' stage"
  63.     unless @DEF or not @{$args{prelink_res}};
  64.  
  65.   my @after_libs = ($OS2::is_aout ? ()
  66.       : $self->perl_inc() . "/libperl_override$self->{config}{lib_ext}");
  67.   # , "-L", "-lperl"
  68.   (@after_libs, @DEF);
  69. }
  70.  
  71. sub link_executable {
  72.   # ldflags is not expecting .exe extension given on command line; remove -Zexe
  73.   my $self = shift;
  74.   local $self->{config}{ldflags} = $self->{config}{ldflags};
  75.   $self->{config}{ldflags} =~ s/(?<!\S)-Zexe(?!\S)//;
  76.   return $self->SUPER::link_executable(@_);
  77. }
  78.  
  79.  
  80. 1;
  81.